.class public Lcom/xingbook/group/b/b;
.super Ljava/lang/Object;


# static fields
.field private static d:Lcom/xingbook/group/b/b;


# instance fields
.field a:Z

.field public b:Ljava/util/List;

.field private c:I

.field private e:Landroid/util/SparseArray;

.field private f:Ljava/util/List;


# direct methods
.method private constructor <init>()V
    .locals 1

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/xingbook/group/b/b;->a:Z

    const/16 v0, 0x14

    iput v0, p0, Lcom/xingbook/group/b/b;->c:I

    new-instance v0, Landroid/util/SparseArray;

    invoke-direct {v0}, Landroid/util/SparseArray;-><init>()V

    iput-object v0, p0, Lcom/xingbook/group/b/b;->e:Landroid/util/SparseArray;

    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    iput-object v0, p0, Lcom/xingbook/group/b/b;->f:Ljava/util/List;

    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    iput-object v0, p0, Lcom/xingbook/group/b/b;->b:Ljava/util/List;

    return-void
.end method

.method public static declared-synchronized a(Landroid/content/Context;)Lcom/xingbook/group/b/b;
    .locals 2

    const-class v1, Lcom/xingbook/group/b/b;

    monitor-enter v1

    :try_start_0
    sget-object v0, Lcom/xingbook/group/b/b;->d:Lcom/xingbook/group/b/b;

    if-nez v0, :cond_0

    new-instance v0, Lcom/xingbook/group/b/b;

    invoke-direct {v0}, Lcom/xingbook/group/b/b;-><init>()V

    sput-object v0, Lcom/xingbook/group/b/b;->d:Lcom/xingbook/group/b/b;

    sget-object v0, Lcom/xingbook/group/b/b;->d:Lcom/xingbook/group/b/b;

    invoke-virtual {v0, p0}, Lcom/xingbook/group/b/b;->b(Landroid/content/Context;)V

    :goto_0
    sget-object v0, Lcom/xingbook/group/b/b;->d:Lcom/xingbook/group/b/b;
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    monitor-exit v1

    return-object v0

    :cond_0
    :try_start_1
    sget-object v0, Lcom/xingbook/group/b/b;->d:Lcom/xingbook/group/b/b;

    invoke-virtual {v0, p0}, Lcom/xingbook/group/b/b;->b(Landroid/content/Context;)V
    :try_end_1
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto :goto_0

    :catchall_0
    move-exception v0

    monitor-exit v1

    throw v0
.end method

.method private a(I)Ljava/util/List;
    .locals 4

    iget v0, p0, Lcom/xingbook/group/b/b;->c:I

    mul-int v1, p1, v0

    iget v0, p0, Lcom/xingbook/group/b/b;->c:I

    add-int/2addr v0, v1

    iget-object v2, p0, Lcom/xingbook/group/b/b;->f:Ljava/util/List;

    invoke-interface {v2}, Ljava/util/List;->size()I

    move-result v2

    if-le v0, v2, :cond_0

    iget-object v0, p0, Lcom/xingbook/group/b/b;->f:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    :cond_0
    new-instance v2, Ljava/util/ArrayList;

    invoke-direct {v2}, Ljava/util/ArrayList;-><init>()V

    iget-object v3, p0, Lcom/xingbook/group/b/b;->f:Ljava/util/List;

    invoke-interface {v3, v1, v0}, Ljava/util/List;->subList(II)Ljava/util/List;

    move-result-object v0

    invoke-interface {v2, v0}, Ljava/util/List;->addAll(Ljava/util/Collection;)Z

    invoke-interface {v2}, Ljava/util/List;->size()I

    move-result v0

    iget v1, p0, Lcom/xingbook/group/b/b;->c:I

    if-ge v0, v1, :cond_1

    invoke-interface {v2}, Ljava/util/List;->size()I

    move-result v0

    :goto_0
    iget v1, p0, Lcom/xingbook/group/b/b;->c:I

    if-lt v0, v1, :cond_3

    :cond_1
    invoke-interface {v2}, Ljava/util/List;->size()I

    move-result v0

    iget v1, p0, Lcom/xingbook/group/b/b;->c:I

    if-ne v0, v1, :cond_2

    new-instance v0, Lcom/xingbook/group/a/a;

    invoke-direct {v0}, Lcom/xingbook/group/a/a;-><init>()V

    const v1, 0x7f02017b

    iput v1, v0, Lcom/xingbook/group/a/a;->a:I

    invoke-interface {v2, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    :cond_2
    return-object v2

    :cond_3
    new-instance v1, Lcom/xingbook/group/a/a;

    invoke-direct {v1}, Lcom/xingbook/group/a/a;-><init>()V

    invoke-interface {v2, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    add-int/lit8 v0, v0, 0x1

    goto :goto_0
.end method

.method private a(Ljava/util/List;Landroid/content/Context;)V
    .locals 7

    const/4 v1, 0x0

    iget-object v0, p0, Lcom/xingbook/group/b/b;->e:Landroid/util/SparseArray;

    invoke-virtual {v0}, Landroid/util/SparseArray;->clear()V

    iget-object v0, p0, Lcom/xingbook/group/b/b;->f:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->clear()V

    iget-object v0, p0, Lcom/xingbook/group/b/b;->b:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->clear()V

    if-nez p1, :cond_1

    :cond_0
    :goto_0
    return-void

    :cond_1
    :try_start_0
    invoke-interface {p1}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v2

    :cond_2
    :goto_1
    invoke-interface {v2}, Ljava/util/Iterator;->hasNext()Z

    move-result v0

    if-nez v0, :cond_3

    iget-object v0, p0, Lcom/xingbook/group/b/b;->f:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->size()I

    move-result v0

    int-to-float v0, v0

    iget v2, p0, Lcom/xingbook/group/b/b;->c:I

    int-to-float v2, v2

    div-float/2addr v0, v2

    float-to-double v2, v0

    invoke-static {v2, v3}, Ljava/lang/Math;->ceil(D)D

    move-result-wide v2

    double-to-int v2, v2

    move v0, v1

    :goto_2
    if-ge v0, v2, :cond_0

    iget-object v1, p0, Lcom/xingbook/group/b/b;->b:Ljava/util/List;

    invoke-direct {p0, v0}, Lcom/xingbook/group/b/b;->a(I)Ljava/util/List;

    move-result-object v3

    invoke-interface {v1, v3}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    add-int/lit8 v0, v0, 0x1

    goto :goto_2

    :cond_3
    invoke-interface {v2}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Ljava/lang/String;

    const-string v3, ","

    invoke-virtual {v0, v3}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v0

    const/4 v3, 0x0

    aget-object v3, v0, v3

    const/4 v4, 0x0

    const/4 v5, 0x0

    aget-object v5, v0, v5

    const-string v6, "."

    invoke-virtual {v5, v6}, Ljava/lang/String;->lastIndexOf(Ljava/lang/String;)I

    move-result v5

    invoke-virtual {v3, v4, v5}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {p2}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v4

    const-string v5, "drawable"

    invoke-virtual {p2}, Landroid/content/Context;->getPackageName()Ljava/lang/String;

    move-result-object v6

    invoke-virtual {v4, v3, v5, v6}, Landroid/content/res/Resources;->getIdentifier(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)I

    move-result v3

    if-eqz v3, :cond_2

    iget-object v4, p0, Lcom/xingbook/group/b/b;->e:Landroid/util/SparseArray;

    const/4 v5, 0x1

    aget-object v5, v0, v5

    invoke-virtual {v4, v3, v5}, Landroid/util/SparseArray;->put(ILjava/lang/Object;)V

    new-instance v4, Lcom/xingbook/group/a/a;

    invoke-direct {v4}, Lcom/xingbook/group/a/a;-><init>()V

    iput v3, v4, Lcom/xingbook/group/a/a;->a:I

    const/4 v3, 0x1

    aget-object v0, v0, v3

    iput-object v0, v4, Lcom/xingbook/group/a/a;->b:Ljava/lang/String;

    iget-object v0, p0, Lcom/xingbook/group/b/b;->f:Ljava/util/List;

    invoke-interface {v0, v4}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_1

    :catch_0
    move-exception v0

    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    goto :goto_0
.end method

.method private static c(Landroid/content/Context;)Ljava/util/List;
    .locals 5

    :try_start_0
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    invoke-virtual {p0}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v1

    invoke-virtual {v1}, Landroid/content/res/Resources;->getAssets()Landroid/content/res/AssetManager;

    move-result-object v1

    const-string v2, "emoji"

    invoke-virtual {v1, v2}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;

    move-result-object v1

    new-instance v2, Ljava/io/BufferedReader;

    new-instance v3, Ljava/io/InputStreamReader;

    const-string v4, "UTF-8"

    invoke-direct {v3, v1, v4}, Ljava/io/InputStreamReader;-><init>(Ljava/io/InputStream;Ljava/lang/String;)V

    invoke-direct {v2, v3}, Ljava/io/BufferedReader;-><init>(Ljava/io/Reader;)V

    :goto_0
    invoke-virtual {v2}, Ljava/io/BufferedReader;->readLine()Ljava/lang/String;

    move-result-object v1

    if-nez v1, :cond_0

    :goto_1
    return-object v0

    :cond_0
    invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    const/4 v0, 0x0

    goto :goto_1
.end method


# virtual methods
.method public a(Landroid/content/Context;ILjava/lang/String;I)Landroid/text/SpannableString;
    .locals 5

    invoke-static {p3}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-eqz v0, :cond_0

    const/4 v0, 0x0

    :goto_0
    return-object v0

    :cond_0
    invoke-virtual {p1}, Landroid/content/Context;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    invoke-virtual {v0, p2}, Landroid/content/res/Resources;->openRawResource(I)Ljava/io/InputStream;

    move-result-object v0

    invoke-static {v0}, Landroid/graphics/BitmapFactory;->decodeStream(Ljava/io/InputStream;)Landroid/graphics/Bitmap;

    move-result-object v0

    const/4 v1, 0x1

    invoke-static {v0, p4, p4, v1}, Landroid/graphics/Bitmap;->createScaledBitmap(Landroid/graphics/Bitmap;IIZ)Landroid/graphics/Bitmap;

    move-result-object v0

    new-instance v1, Landroid/text/style/ImageSpan;

    invoke-direct {v1, p1, v0}, Landroid/text/style/ImageSpan;-><init>(Landroid/content/Context;Landroid/graphics/Bitmap;)V

    new-instance v0, Landroid/text/SpannableString;

    invoke-direct {v0, p3}, Landroid/text/SpannableString;-><init>(Ljava/lang/CharSequence;)V

    const/4 v2, 0x0

    invoke-virtual {p3}, Ljava/lang/String;->length()I

    move-result v3

    const/16 v4, 0x21

    invoke-virtual {v0, v1, v2, v3, v4}, Landroid/text/SpannableString;->setSpan(Ljava/lang/Object;III)V

    goto :goto_0
.end method

.method public b(Landroid/content/Context;)V
    .locals 2

    iget-boolean v0, p0, Lcom/xingbook/group/b/b;->a:Z

    if-eqz v0, :cond_1

    :cond_0
    :goto_0
    return-void

    :cond_1
    if-nez p1, :cond_2

    invoke-static {}, Lcom/xingbook/park/activity/HomeActivity;->b()Landroid/content/Context;

    move-result-object p1

    :cond_2
    if-eqz p1, :cond_0

    invoke-static {p1}, Lcom/xingbook/group/b/b;->c(Landroid/content/Context;)Ljava/util/List;

    move-result-object v0

    invoke-direct {p0, v0, p1}, Lcom/xingbook/group/b/b;->a(Ljava/util/List;Landroid/content/Context;)V

    const/4 v0, 0x0

    const/4 v1, 0x0

    invoke-static {v0, v1}, Lcom/xingbook/group/b/c;->a(Landroid/content/Context;Z)Lcom/xingbook/group/b/c;

    move-result-object v0

    iget-object v1, p0, Lcom/xingbook/group/b/b;->e:Landroid/util/SparseArray;

    invoke-virtual {v0, v1, p1}, Lcom/xingbook/group/b/c;->a(Landroid/util/SparseArray;Landroid/content/Context;)Z

    move-result v0

    iput-boolean v0, p0, Lcom/xingbook/group/b/b;->a:Z

    goto :goto_0
.end method
